#pragma once
#include "../GridCtrl_src/GridCell.h"
#include "../GridCtrl_src/GridCtrl.h"

#define GVN_BEGINMULTICHECK     CBEN_BEGINEDIT
#define GVN_ENDMULTICHECK       CBEN_ENDEDIT


class CGridCellCheckCombo : public CGridCell
{
	friend class CGridCtrl;
	DECLARE_DYNCREATE(CGridCellCheckCombo)

public:
	CGridCellCheckCombo();
	virtual ~CGridCellCheckCombo();

public:
	void SetOptions(const CStringArray& ar);
	void SetSelOptions(const CStringArray& ar);
	const CStringArray& GetSelOptions() const;
	void EndSel();

protected:
	CRect GetButtonPlacement();

public:
	virtual void EndEdit();

protected:
	virtual BOOL Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd = TRUE);
	virtual BOOL GetTextRect(LPRECT pRect);

protected:
	virtual void OnEndEdit();
	virtual void OnClick(CPoint PointCellRelative);
	virtual void OnDblClick(CPoint PointCellRelative);

protected:
	BOOL         m_bPopList;
	int          m_nRow;
	int          m_nCol;
	CRect        m_Rect;
	CStringArray m_Strings;
	CStringArray m_SelStrings;
};

class CInPlaceCheckList : public CListCtrl
{
public:
	CInPlaceCheckList(CWnd* pParent,            // parent
		              CRect& rect,              // dimensions & location
		              UINT nID,                 // control ID
		              int nRow, int nColumn,    // row and column
		              CStringArray& Items,      // Items in list
		              CStringArray& InitItems); // initial selection
	virtual ~CInPlaceCheckList();

public:
	const CStringArray& GetSelOptions() const;

protected:
	int GetCorrectDropWidth();

protected:
	virtual void PostNcDestroy();

public:
	void EndEdit();

protected:
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg UINT OnGetDlgCode();
	/*afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);*/

	DECLARE_MESSAGE_MAP()

private:
	int		 m_nNumLines;
	CStringArray  m_InitItems;
	int		 m_nRow;
	int		 m_nCol;
	UINT     m_nLastChar; 
	BOOL	 m_bExitOnArrows;
};
